package com.dmx.platform.dao.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;

import com.dmx.fw.bean.PageInfo;
import com.dmx.fw.dao.hibernateimpl.BaseDaoImpl;
import com.dmx.platform.dao.OrderDao;
import com.dmx.platform.entity.TOrder;

/**
 *@author:Beni Yang
 *@date:2012-8-29
 *@function:
 */
public class OrderDaoImpl extends BaseDaoImpl implements OrderDao {

	@Override
	public TOrder getOrderByPassword(String pwd,Integer businessId) {
		String queryString="from TOrder where secretKey='"+pwd+"' and baseId="+businessId;
		try{
			List<TOrder> list=this.find(queryString);
			if(!list.isEmpty()){
				return list.get(0);
			}
		}catch(Exception e){
//			e.printStackTrace();
			log.error("Get order failed ["+pwd+"] "+e.getMessage());
		}
		return null;

	}

	@Override
	public boolean saveOrUpdateOrder(TOrder order) {
		try{
			this.getHibernateTemplate().saveOrUpdate(order);
			return true;
		}catch(Exception e){
			log.error("Save or update order failed "+e.getMessage());
			
		}
		
		return false;
		
	}

	

}
